home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 4
/
FM Towns Free Software Collection 4 - Disc 1.iso
/
t_os
/
tmdsp
/
tclr.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-18
|
2KB
|
90 lines
/*
TCLR.C Ver 0.02 1991.08.09 by Y.Kurihara (Nif PDC01620)"
T-MENU の画面にちょっかいを出すプログラム その1
(1) TCLR
(2) TCLR <X座標> <Y座標> <桁数> <行数>
(1) 全画面をクリア
(2) 指定範囲をクリアする
*/
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <machine.h>
#define X0 (2)
#define Xl (76)
#define Y0 (7)
#define Yl (20)
#define VRAM( offset ) ( (char far *)MK_FP( 0xc000,( offset ) ) )
#define PORTpage (0xff83)
#define PORTplane (0xff81)
#define Y1page (256)
void clr( int x1,int y1,int x2,int y2 )
{
unsigned int x,y;
unsigned int off;
if( y1 < Y1page ) {
outp( PORTpage, 0x00 );
off = y1 * 128;
} else {
outp( PORTpage, 0x10 );
off = ( y1 - Y1page )* 128;
}
for( y = y1; y <= y2; y++ ) {
if( y == Y1page ) {
outp( PORTpage, 0x10 );
off -= Y1page * 128;
}
for( x = x1; x <= x2; x++ ) {
*VRAM( off + x ) = 0xff;
}
off += 128;
}
return;
}
main( int argc,char **argv )
{
int save_page;
int save_plane;
int x1 = X0;
int y1 = Y0;
int x2 = Xl;
int y2 = Yl;
if( argc >= 2 ) x1 = atoi( argv[1] );
if( argc >= 3 ) y1 = atoi( argv[2] );
if( argc >= 4 ) x2 = atoi( argv[3] );
if( argc >= 5 ) y2 = atoi( argv[4] );
if( x1 < 0 || y1 < 0 || x2 < 1 || y2 < 1 ) exit(1);
if( x1 >= 80 || y1 >= 30 ) exit(1);
if( ( x2 = x1 + x2 - 1 ) >= 80 ) x2 = 79;
if( ( y2 = y1 + y2 - 1 ) >= 30 ) y2 = 29;
if( argc < 2 ) {
y1 = y1 *16 - 4;
y2 = y2 *16 + 19;
} else {
y1 = y1 *16;
y2 = y2 *16 + 15;
}
save_page = inp( PORTpage );
save_plane = inp( PORTplane );
outp( PORTplane,15 );
clr( x1,y1,x2,y2 );
outp( PORTpage, save_page );
outp( PORTplane, save_plane );
exit( 0 );
}